import { AddressItem, AddressParams } from "@/types/address";
import { httpRequest } from "@/utils/http";

// 新增收货地址API
export const postAddressAPI = (data: AddressParams) => {
    return httpRequest({
        method: 'POST',
        url: '/member/address',
        data,
    });
};

// 查询收货地址列表API
export const getAddressAPI = () => {
    return httpRequest<AddressItem[]>({
        method: 'GET',
        url: '/member/address',
    });
};

// 按id查询收货地址API
export const getAddressByIdAPI = (id: string) => {
    return httpRequest<AddressItem>({
        method: 'GET',
        url: `/member/address/${id}`,
    });
};

// 按id修改收货地址API
export const putAddressByIdAPI = (id: string, data: AddressParams) => {
    return httpRequest({
        method: 'PUT',
        url: `/member/address/${id}`,
        data,
    });
};

// 按id删除收货地址API
export const deleteAddressByIdAPI = (id: string) => {
    return httpRequest({
        method: 'DELETE',
        url: `/member/address/${id}`,
    });
};